﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class UIMCT : ViewBase
    {
        #region ==IsMachineReady===========
        public static readonly DependencyProperty IsMachineReadyProperty = DependencyProperty.Register("IsMachineReady",
        typeof(bool), typeof(UIMCT),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsMachineReadyChanged));
        public bool IsMachineReady
        {
            get
            {
                return (bool)GetValue(IsMachineReadyProperty);
            }
            set
            {
                SetValue(IsMachineReadyProperty, value);
            }
        }
        private static void OnIsMachineReadyChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.IsMachineReady = (bool)e.NewValue;
                src.OnMachineReadyChg((bool)e.NewValue);
            }
        }
        public virtual void OnMachineReadyChg(bool value)
        {

        }
        #endregion 
        #region ==ZLANSVRSTATUS===========
        public static readonly DependencyProperty ZLANSVRSTATUSProperty = DependencyProperty.Register("ZLANSVRSTATUS",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZLANSVRSTATUSChanged));
        public string ZLANSVRSTATUS
        {
            get
            {
                return TMV.ZLANSVRSTATUS;
            }
            set
            {
                SetValue(ZLANSVRSTATUSProperty, value);
                if(TMV!=null)
                {
                    TMV.ZLANSVRSTATUS = value;
                }
            }
        }
        private static void OnZLANSVRSTATUSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZLANSVRSTATUS = (string)e.NewValue;
            }
        }
        #endregion

        #region ==PLCIP===========
        public static readonly DependencyProperty PLCIPProperty = DependencyProperty.Register("PLCIP",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPLCIPChanged));
        public string PLCIP
        {
            get
            {
                return (string)GetValue(PLCIPProperty);
            }
            set
            {
                SetValue(PLCIPProperty, value);
            }
        }
        private static void OnPLCIPChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.PLCIP = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP0===========
        public static readonly DependencyProperty ZP0Property = DependencyProperty.Register("ZP0",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP0Changed));
        public string ZP0
        {
            get
            {
                return (string)GetValue(ZP0Property);
            }
            set
            {
                SetValue(ZP0Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP0 = value;
                }
            }
        }
        private static void OnZP0Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP0 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP1===========
        public static readonly DependencyProperty ZP1Property = DependencyProperty.Register("ZP1",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP1Changed));
        public string ZP1
        {
            get
            {
                return (string)GetValue(ZP1Property);
            }
            set
            {
                SetValue(ZP1Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP1 = value;
                }
            }
        }
        private static void OnZP1Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP1 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP2===========
        public static readonly DependencyProperty ZP2Property = DependencyProperty.Register("ZP2",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP2Changed));
        public string ZP2
        {
            get
            {
                return (string)GetValue(ZP2Property);
            }
            set
            {
                SetValue(ZP2Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP2 = value;
                }
            }
        }
        private static void OnZP2Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP2 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP3===========
        public static readonly DependencyProperty ZP3Property = DependencyProperty.Register("ZP3",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP3Changed));
        public string ZP3
        {
            get
            {
                return (string)GetValue(ZP3Property);
            }
            set
            {
                SetValue(ZP3Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP3 = value;
                }
            }
        }
        private static void OnZP3Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP3 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP4===========
        public static readonly DependencyProperty ZP4Property = DependencyProperty.Register("ZP4",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP4Changed));
        public string ZP4
        {
            get
            {
                return (string)GetValue(ZP4Property);
            }
            set
            {
                SetValue(ZP4Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP4 = value;
                }
            }
        }
        private static void OnZP4Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP4 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP5===========
        public static readonly DependencyProperty ZP5Property = DependencyProperty.Register("ZP5",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP5Changed));
        public string ZP5
        {
            get
            {
                return (string)GetValue(ZP5Property);
            }
            set
            {
                SetValue(ZP5Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP5 = value;
                }
            }
        }
        private static void OnZP5Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP5 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP6===========
        public static readonly DependencyProperty ZP6Property = DependencyProperty.Register("ZP6",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP6Changed));
        public string ZP6
        {
            get
            {
                return (string)GetValue(ZP6Property);
            }
            set
            {
                SetValue(ZP6Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP6 = value;
                }
            }
        }
        private static void OnZP6Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP6 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP7===========
        public static readonly DependencyProperty ZP7Property = DependencyProperty.Register("ZP7",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP7Changed));
        public string ZP7
        {
            get
            {
                return (string)GetValue(ZP7Property);
            }
            set
            {
                SetValue(ZP7Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP7 = value;
                }
            }
        }
        private static void OnZP7Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP7 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP8===========
        public static readonly DependencyProperty ZP8Property = DependencyProperty.Register("ZP8",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP8Changed));
        public string ZP8
        {
            get
            {
                return (string)GetValue(ZP8Property);
            }
            set
            {
                SetValue(ZP8Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP8 = value;
                }
            }
        }
        private static void OnZP8Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP8 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP9===========
        public static readonly DependencyProperty ZP9Property = DependencyProperty.Register("ZP9",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP9Changed));
        public string ZP9
        {
            get
            {
                return (string)GetValue(ZP9Property);
            }
            set
            {
                SetValue(ZP9Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP9 = value;
                }
            }
        }
        private static void OnZP9Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP9 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==ZP10===========
        public static readonly DependencyProperty ZP10Property = DependencyProperty.Register("ZP10",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZP10Changed));
        public string ZP10
        {
            get
            {
                return (string)GetValue(ZP10Property);
            }
            set
            {
                SetValue(ZP10Property, value);
                if (dwMaster != null)
                {
                    TMV.ZP10 = value;
                }
            }
        }
        private static void OnZP10Changed(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.ZP10 = (string)e.NewValue;
            }
        }
        #endregion
        #region ==DATASEND===========
        public static readonly DependencyProperty DATASENDProperty = DependencyProperty.Register("DATASEND",
            typeof(string), typeof(UIMCT),
            new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnDATASENDChanged));
        public string DATASEND
        {
            get
            {
                return (string)GetValue(DATASENDProperty);
            }
            set
            {
                SetValue(DATASENDProperty, value);
                if(dwMaster!=null)
                {
                    TMV.DATASEND = value;
                }
            }
        }
        private static void OnDATASENDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIMCT;
            if (src != null)
            {
                src.DATASEND = (string)e.NewValue;
            }
        }
        #endregion 
        public UIMCT()
        {

        }
     
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e); 
        } 
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if(dwMaster==null)
            {
                PLCIP = "";
                KEY = "";
            }
            else
            {
                PLCIP = TMV.LOCALIP;
                KEY = TMV.LOCALIP +":"+ TMV.LOCALPORT;
            }  
        }  
    }
    public partial class UIMCT : ViewBase
    {
        public VICC_ZLAN TMV
        {
            get
            {
                return (VICC_ZLAN)MV;
            }
        }
  
    }
}
